package com.xyht.sca_s.student_manage_system.modules.rxRegistrationExamine.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.annotation.RequestPass;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationExamine.entity.req.RxRegistrationExamineApplicationAllowReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationExamine.entity.req.RxRegistrationExamineApplicationReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationExamine.entity.req.RxRegistrationExamineBlackListReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationExamine.service.RxRegistrationExamineApplicationService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 审批应用 黑名单学生入学申请 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-05-15
 */
@RestController
@RequestMapping("/rxRegistrationExamine/apply")
@SecretBody
public class RxRegistrationExamineApplicationController {
    @Resource
    private RxRegistrationExamineApplicationService rxRegistrationExamineApplicationService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @PostMapping("/add")
    @ApiModelProperty("学生黑名单申请")
    @RequestPass
    public ResponseResult addStudentBlacklistApplication(@RequestBody RxRegistrationExamineApplicationReq applicationReq) {
        return rxRegistrationExamineApplicationService.addStudentBlacklistApplication(applicationReq);
    }

    @GetMapping("/stuList")
    @ApiModelProperty("获取学生黑名单申请")
    @RequestPass
    public ResponseResult getBlackList(@RequestParam(value = "stuIdCard") String stuIdCard) {
        return rxRegistrationExamineApplicationService.getStudentBlacklistApplicationByStudent(stuIdCard);
    }

    @PostMapping("/allow")
    @ApiModelProperty("审批学生申请")
    public ResponseResult addStudentBlacklistApplication(@RequestBody RxRegistrationExamineApplicationAllowReq allowReq, HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return rxRegistrationExamineApplicationService.allowBlacklistApplication(allowReq,user_id);
    }

    @GetMapping("/list")
    @ApiModelProperty("获取所有申请列表")
    public ResponseResult getStudentBlacklistApplicationList(@RequestParam(value = "searchStr", required = false) String searchStr,
                                       @RequestParam(value = "status", required = false) Integer status,
                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return rxRegistrationExamineApplicationService.getStudentBlacklistApplicationList(searchStr,status,pageNum, pageSize);
    }

}

